if (inweo.get("inweo.widgets.button") != true) {
	inweo.set("inweo.widgets.button", true);
	inweo.widgets.button = inweo.core.widget.extend({
		disable: function(bool) {
			if (bool == true) {
				this.widget.setProperty("disabled", "true");
				this.label.disable(true);
				this.image.setStyle("opacity", 0.2); /* poor man disable effect */
				this.widget.addClass("buttonDisabled");
			} else if (bool == false) {
				this.widget.setProperty("disabled", "false");
				this.label.disable(false);
				this.image.setStyle("opacity", 1);
				this.widget.removeClass("buttonDisabled");
			} else {
				return this.disabled();
			}
		},
		disabled: function() {
			return this.widget.hasClass("buttonDisabled");
		},
		picture: function(src) {
			if (src != null) {
				this.image.src = src;
				this.image.setStyle("display", "inline");
				return true;
			} else {
				return this.image.src || null;
			}		
		},
		initialize: function() {
			inweo.require("label");
			var self = this;

			this.widget =  new Element("div");
			this.widget.setProperty("role", "button");
			this.widget.addClass("button");
			this.widget.addClass("widgetUnselectable");
			this.registerWidget("button");

			this.image = new Element("img");
			this.image.injectInside(this.widget);
			this.image.setStyle("display", "none");

			this.label = new inweo.widgets.label();
			this.label.widget.injectInside(this.widget);

			this.widget.addEvent("mouseenter", function() {
				if (self.disabled() == true) {
					return;
				}
				this.addClass("buttonHover");
			});
			this.widget.addEvent("mouseleave", function() {
				this.removeClass("buttonHover");
			});
			this.widget.addEvent("mousedown", function() {
				if (self.disabled() == true) {
					return;
				}
				this.addClass("buttonPressed");
			});
			this.widget.addEvent("mouseup", function() {
				this.removeClass("buttonPressed");
			});
		},
		text: function(string) {
			if (string != null) {
				this.label.text(string);
				return true;
			} else {
				return this.label.text() || null;
			}
		}
	});
	inweo.widgets.pushButton = inweo.widgets.button.extend({
		initialize: function(){
			this.parent();
			this.widget.addClass("pushButton");
			this.widget.addEvent("mouseleave", function() {
				this.removeClass("buttonPressed");
			});
		}
	});
	inweo.widgets.toggleButton = inweo.widgets.button.extend({
		check: function(bool) {
			if (bool == true) {
				this.widget.addClass("buttonPressed");
				this.widget.setProperty("checked", true);
			} else if (bool == false) {
				this.widget.removeClass("buttonPressed");
				this.widget.setProperty("checked", false);
			} else {
				return this.checked();
			}
		},
		checked: function() {
			return this.widget.hasClass("buttonPressed");
		},
		initialize: function() {
			this.parent();
			this.widget.addClass("toggleButton");
			this.widget.setProperty("checked", false);

			var self = this;
			this.widget.addEvent("click", function() {
				var check = self.widget.getProperty("checked");
				if (check == true) {
					self.check(false);
				} else if (check == false) {
					self.check(true);
				}
			});
		}
	});
	inweo.widgets.checkboxButton = inweo.widgets.button.extend({
		disable: function(bool) {
			if (bool == null) {
				return this.disabled();
			}
			this.parent();
			this.checkbox.disabled = bool;
			this.label.disable(bool);
		},
		disabled: function() {
			return this.checkbox.disabled;
		},
		picture: function(src) {},
		check: function(bool) {
			this.checkbox.checked = bool;
		},
		checked: function() {
			return this.checkbox.checked;
		},
		initialize: function(bool) {
			this.parent();
			this.widget.addClass("checkboxButton");
			
			this.widget.getElement("img").remove();

			var self = this;
			
			this.checkbox = new Element("input");
			this.checkbox.setProperty("type", "checkbox");
			this.checkbox.checked = bool || false;
			this.checkbox.onclick = function() {
				self.checkbox.checked = (self.checkbox.checked == true) ? false : true;
			}
			this.checkbox.injectTop(this.widget);

			this.widget.addEvent("click", function() {
				if (self.disabled() == true) {
					return;
				}
				var check = self.checkbox.checked;
				if (check == true) {
					self.check(false);
				} else if (check == false) {
					self.check(true);
				}
			});			
		}
	});
	inweo.widgets.radioButton = inweo.widgets.button.extend({
		disable: function(bool) {
			if (bool == null) {
				return this.disbaled();
			}
			this.parent();
			this.radio.disabled = bool;
			this.label.disable(bool);
		},
		disabled: function() {
			return this.radio.disabled;
		},
		picture: function(src) {},
		check: function(bool) {
			if (bool == null) {
				return this.checked();
			}
			if (navigator.appName == "Microsoft Internet Explorer") {
				$$("body")[0].getElements("input[name=" + this.group + "]").each(function(radio) {
					radio.checked = false;
				});
			}
			this.radio.checked = bool;
		},
		checked: function() {
			return this.radio.checked;
		},
		initialize: function(group) {
			this.parent();
			this.widget.addClass("radioButton");			
			
			this.widget.getElement("img").remove();

			var self = this;
			this.group = group;
			
			this.radio = new Element("input");
			this.radio.setProperty("type", "radio");
			this.radio.setProperty("name", this.group);
			this.radio.checked = false;
			this.radio.onclick = function() {
				if (navigator.appName == "Microsoft Internet Explorer") {
					self.radio.checked = (self.radio.checked == true) ? false : true;
				}
			}
			this.radio.injectTop(this.widget);

			this.widget.addEvent("click", function() {
				if (self.disabled() == true) {
					return;
				}
				var check = self.radio.checked;
				if (check == true) {
					self.check(false);
				} else if (check == false) {
					self.check(true);
				}
			});
		}
	});
}